package cn.tedu.egmvc1.controller;

import cn.tedu.egmvc1.mapper.AddressMapper;
import cn.tedu.egmvc1.pojo.entity.Address;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping(value = "/address/")
public class AddressController {
    @Autowired
    private AddressMapper addressMapper;

    @PostMapping(value = "insert")
    public String insert(Address address){
        System.out.println("address ="+address);
        addressMapper.insert(address);
        return "添加成功";
    }
    @GetMapping(value = "select")
        public List<Address> select(){
        return addressMapper.select();
    }

    @PostMapping(value = "delete")
    public String deleteUser(int id){
        System.out.println("id="+id);
        addressMapper.delete(id);
        return "删除成功";
    }

    @PostMapping(value = "update")
    public String updateUser(Address address){
        System.out.println("address="+address);
        addressMapper.update(address);
        return "修改成功";
    }
}
